package org.linlinjava.litemall.db.service;

import org.linlinjava.litemall.db.dao.AgedmallGoodsPartsMapper;
import org.linlinjava.litemall.db.domain.AgedmallGoodsParts;
import org.linlinjava.litemall.db.domain.AgedmallGoodsPartsExample;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class AgedmallGoodsPartsService {
    @Resource
    private AgedmallGoodsPartsMapper agedmallGoodsPartsMapper;

    public List<AgedmallGoodsParts> getByGoodsId(Integer goodsId) {
        AgedmallGoodsPartsExample example = new AgedmallGoodsPartsExample();
        example.or().andDeletedEqualTo(false)
                .andGoodsIdEqualTo(goodsId);
        return agedmallGoodsPartsMapper.selectByExample(example);
    }

    public List<AgedmallGoodsParts> getByGoodsIdAndSpecId(Integer goodsId, Integer specId) {
        AgedmallGoodsPartsExample example = new AgedmallGoodsPartsExample();
        example.or().andDeletedEqualTo(false)
                .andGoodsIdEqualTo(goodsId)
                .andSpecIdEqualTo(specId);
        return agedmallGoodsPartsMapper.selectByExample(example);
    }
    public List<AgedmallGoodsParts> getByGoodsIdAndSpecIdList(Integer goodsId, List<Integer> specIdList) {
        AgedmallGoodsPartsExample example = new AgedmallGoodsPartsExample();
        example.or().andDeletedEqualTo(false)
                .andGoodsIdEqualTo(goodsId)
                .andSpecIdIn(specIdList);
        return agedmallGoodsPartsMapper.selectByExample(example);
    }

    public AgedmallGoodsParts getByGoodsIdAndCustGoodsId(Integer goodsId, Integer custGoodsId) {
        AgedmallGoodsPartsExample example = new AgedmallGoodsPartsExample();
        example.or().andDeletedEqualTo(false)
                .andGoodsIdEqualTo(goodsId)
                .andCustomizedGoodsIdEqualTo(custGoodsId);
        return agedmallGoodsPartsMapper.selectOneByExample(example);
    }
}
